CLASS ycl_moon_sql_test DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES: if_amdp_marker_hdb,
      if_oo_adt_classrun .

  PROTECTED SECTION.
  PRIVATE SECTION.
    METHODS:schedule.
ENDCLASS.



CLASS YCL_MOON_SQL_TEST IMPLEMENTATION.


  METHOD if_oo_adt_classrun~main.

    me->schedule( ).

*    DATA(lo_destination) = cl_http_destination_provider=>create_by_url(
*        'https://api.kuleu.com/api/suiji_renshe' ).
*    DATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination( lo_destination ).
*
*    DATA(lo_response) = lo_client->execute( i_method = if_web_http_client=>get ).
*    DATA(ld_content_type) = lo_response->get_content_type( ).
*    DATA(ls_status) = lo_response->get_status( ).
*    DATA(ld_text) = lo_response->get_text( ).
*
*    out->write( ld_text ).

*   SELECT taxcode, conditionratevalue
*   from I_SalesDocItemPricingElement
*  WHERE SalesDocument = '0000000083'
*   and SalesDocumentItem = '10'
*   and ConditionType = 'TTX1'
*   into TABLE @data(lt_pticeEL).


*    SELECT *
*    FROM I_SalesOrderItemTextTP
*    INTO TABLE @DATA(lt_text).

*DELETE FROM zMES_T_0018.

*          SELECT DISTINCT materialdocumentyear, materialdocument
*            FROM i_materialdocumentitem_2
*           WHERE postingdate = '20240913'
*             AND deliverydocument =  '0084000012'
*             AND goodsmovementtype = '657'
*             AND goodsmovementiscancelled = ''
*            INTO TABLE @DATA(lt_matdoc).
  ENDMETHOD.


  METHOD schedule.
    DATA lv_job_text TYPE cl_apj_rt_api=>ty_job_text VALUE 'Trigger Custom Job'.
    DATA lv_template_name TYPE cl_apj_rt_api=>ty_template_name VALUE 'YMOON_CL_APPJOB_SAMPLE'.
    DATA ls_start_info TYPE cl_apj_rt_api=>ty_start_info.
    DATA ls_scheduling_info TYPE cl_apj_rt_api=>ty_scheduling_info.
    DATA ls_end_info TYPE cl_apj_rt_api=>ty_end_info.
    DATA lv_jobname TYPE cl_apj_rt_api=>ty_jobname.
    DATA lv_jobcount TYPE cl_apj_rt_api=>ty_jobcount.

********** Set scheduling options *******************
    ls_start_info-start_immediately = 'X'.
    ls_scheduling_info-periodic_granularity = ''.
    ls_scheduling_info-periodic_value = 1.
    ls_scheduling_info-test_mode = abap_false.
    ls_scheduling_info-timezone = 'CET'.
    ls_end_info-type = 'NUM'.
    ls_end_info-max_iterations = 3.
*****************************************************

    TRY.
        cl_apj_rt_api=>schedule_job(
          EXPORTING
            iv_job_template_name = lv_template_name
            iv_job_text          = lv_job_text
            is_start_info        = ls_start_info
            is_scheduling_info   = ls_scheduling_info
            is_end_info          = ls_end_info
          IMPORTING
            ev_jobname           = lv_jobname
            ev_jobcount          = lv_jobcount
        ).
      CATCH cx_apj_rt INTO DATA(exc).
        DATA(lv_txt) = exc->get_longtext( ).
        DATA(ls_ret) = exc->get_bapiret2( ).
    ENDTRY.
  ENDMETHOD.
ENDCLASS.
